/****************************************************
          File Name:hex2utf8.c
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Wed 18 Feb 2015 02:22:01 PM CST
*****************************************************/

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

static void conv(char *raw)
{
    register int i = 0;
    for(;*(raw+i); raw++, i++)
    {
        *raw = *(raw+i) >= 'A'?(((*(raw+i)) - 'A')+10) << 4 :(*(raw+i) - '0') << 4;
        *raw+=*(raw+i+1) >= 'A'?((*(raw+i+1)) - 'A')+10:(*(raw+i+1) - '0');  
	}
    *raw = '\0';
}

int main(int argc, char *argv[])
{
    char *in;

    in = (char *)malloc(strlen(argv[1]) + 1);
    strcpy(in, argv[1]);

    conv(in);
    printf("orignal string:%s\n", in);
    free(in);
    return 0;
}
